package com.fb.cvstool.netbeans;

import java.io.File;
import java.io.IOException;

import org.apache.commons.io.FileUtils;
import org.apache.commons.lang.StringUtils;
import org.netbeans.lib.cvsclient.command.CommandException;
import org.netbeans.lib.cvsclient.connection.AuthenticationException;

public class TestnetBeansCVS {
	/*
	 * public static void main(String[] args) throws CommandAbortedException,
	 * CommandException, AuthenticationException, IOException { String cvsroot =
	 * ":pserver:cvsadmin:cvsadmin@localhost:/CVS_repository/root"; String
	 * localPath = "D:/cvs_checkout/818"; NetBeansCVSClient client = new
	 * NetBeansCVSClient(cvsroot, localPath); String file =
	 * "\\CVS_repository\\root\\WebRoot\\WEB-INF\\lib\\antlr.jar"; int cnt =
	 * client.checkStatus(file);
	 * 
	 * }
	 */
	public static void main(String[] args) throws AuthenticationException,
			IOException, CommandException {
		/*
		 * String cvsroot =
		 * ":pserver:cvsadmin:cvsadmin@localhost:/CVS_repository/root"; String
		 * localPath = "D:/cvs_checkout/818/CVS_repository";
		 * 
		 * CVSClient cvsclient = new CVSClient(cvsroot);
		 * cvsclient.openConnection(); cvsclient.setLocalPath(localPath); String
		 * fName =
		 * "D:/cvs_checkout/818/CVS_repository/root/WebRoot/WEB-INF/testdir/empty12.txt"
		 * ; cvsclient.excute(cvsclient.add(new String[] { fName }));
		 * cvsclient.closeConnection(); cvsclient.openConnection();
		 * 
		 * cvsclient.excute(cvsclient.commit(new String[] { fName }));
		 * cvsclient.closeConnection();
		 */

		// D:/cvs_checkout/818/CVS_repository/root2/WebRoot/WEB-INF/testdir/readme.txt
		// D:/cvs_checkout/817/CVS_repository/root/WebRoot/WEB-INF/testdir/

		String localpath1 = "D:\\cvs_checkout\\818\\CVS_repository\\root2";
		String localpath2 = "D:\\cvs_checkout\\817\\CVS_repository\\root";

		String file = "WebRoot\\WEB-INF\\testdir\\readme.txt";
		// String path = "CVS_repository/root/WebRoot/WEB-INF/testdir/";

		File f1 = new File(localpath1 + File.separator + file);
		System.out.println("-" + f1.getAbsolutePath());
		if (f1.exists()) {
			String f1path = f1.getAbsolutePath();
			if (f1path.indexOf(localpath1) > -1) {

				int loc = f1path.indexOf(localpath1);
				f1path = f1path.substring(0, loc) + localpath2 + File.separator
						+ f1path.substring(loc + 1 + localpath1.length());
				FileUtils.moveFile(f1, new File(f1path));
			}
		}

	}

}
